<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of randperm2</title>
  <meta name="keywords" content="randperm2">
  <meta name="description" content="Returns a random permutation of integers.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html matlab -->
<h1>randperm2
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Returns a random permutation of integers.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function p = randperm2(n,k); </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Returns a random permutation of integers. 

 randperm2(n) is a random permutation of the integers from 1 to n.  For example,
 randperm2(6) might be [2 4 5 6 1 3].  randperm2(n,k) is only returns the first k
 elements of the permuation, so for example randperm2(6) might be [2 4].
 
 This is a faster version of randperm.m if only need first k&lt;&lt;n elements of the random
 permutation.  Also uses less random bits (only k).  Note that this is an implementation
 O(k), versus the matlab implementation which is O(nlogn), however, in practice it is
 often slower for k=n because it uses a loop.

 INPUTS
   n     - permute 1:n
   k   - keep only first k outputs

 OUTPUTS
   p     - k length vector of permutations

 EXAMPLE
   randperm2(10,5)

 DATESTAMP
   29-Sep-2005  2:00pm

 See also RANDPERM</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="../classify/kmeans2.html" class="code" title="function [IDX,C,sumd] = kmeans2( X,k,varargin )">kmeans2</a>	Very fast version of kmeans clustering.</li></ul>
<!-- crossreference -->



<hr><address>Generated on Wed 03-May-2006 23:48:50 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>